package com.liuanbang.saro.sarodemo.ui.activity;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.liuanbang.saro.sarodemo.R;
import com.liuanbang.saro.sarodemo.base.BaseActivity;
import com.liuanbang.saro.sarodemo.ui.items.recyclerview.CommonAdapter;
import com.liuanbang.saro.sarodemo.ui.items.recyclerview.TestVo;
import com.liuanbang.saro.sarodemo.ui.items.recyclerview.base.ViewHolder;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by 刘安邦 on 2017/3/17.
 * Email:liuanbang@aliyun.com
 * 描述:       2017/3/17
 * 修改:
 */

public class TestActivity extends BaseActivity {
    @Bind(R.id.recyclerView)
    RecyclerView recyclerView;

    private Context context = this;

    private CommonAdapter<TestVo> mAdapter;

    @Override
    protected void initView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_test);
        ButterKnife.bind(this);

        String[] arrString = getResources().getStringArray(R.array.arrIconUrls);
        ArrayList list = new ArrayList();
        Log.i("-->>", "onViewInit: " + list.size());
        for (int i = 0; i < arrString.length; i++) {
            TestVo vo = new TestVo();
            vo.name = "测试" + i;
            vo.url = arrString[i];
            list.add(vo);
        }

        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        mAdapter = new CommonAdapter<TestVo>(this, R.layout.custom_test_item, list) {
            @Override
            protected void convert(ViewHolder holder, TestVo testVo, int position) {
                Glide.with(context).load(testVo.url).into((ImageView) (holder.getView(R.id.imageView)));
                holder.setText(R.id.textView, testVo.name);
            }
        };

        recyclerView.setAdapter(mAdapter);
    }

    @Override
    protected void setListener() {

    }

    @Override
    protected void processLogic(Bundle savedInstanceState) {

    }

    @Override
    public Toolbar getToolbar() {
        return null;
    }
}
